//
//  SQConfirmTableViewCell.m
//  energy
//
//  Created by 周曼迪 on 2021/7/7.
//

#import "SQConfirmTableViewCell.h"
#import "SQListModel.h"
#import "SQConfirmModel.h"
#import "SQRectificationModel.h"
#import "SQAcceptanceModel.h"

#import "NSString+NCDate.h"

@implementation SQConfirmTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    [self.view_bg SQCornerLineWidth:W(1) LineColor:[UIColor colorNamed:@"f1Color"]];
    [self.view_bg SQCornerRadius:W(5)];
    
}
+(CGFloat)cellHeight:(BaseModel *)model{
    return W(150);
}

-(void)setModel:(BaseModel<BaseCellModelProtocol> *)model{
    if ([model isKindOfClass:SQListModelData.class]) {
        SQListModelData * dataModel = model;
        
        [self.btn_confirm setTitle:@"修改" forState:UIControlStateNormal];
        self.lab_area.text = dataModel.site_area;
        self.lab_time.text = [NSString formateDate:[dataModel.hd_report_time substringWithRange:NSMakeRange(6,13)]];
        self.lab_description.text = dataModel.hd_danger_description;
        if ([dataModel.hd_audit_status isEqualToString:@"0"]) {
            /**待确认*/
            self.lab_type.text = @"待确认";
            self.img_type.image = [UIImage imageNamed:@"type1"];
        }else if ([dataModel.hd_audit_status isEqualToString:@"1"]) {
            /**待整改*/
            self.lab_type.text = @"待整改";
            self.img_type.image = [UIImage imageNamed:@"type2"];
        }else if ([dataModel.hd_audit_status isEqualToString:@"2"]) {
            /**待验收*/
            self.lab_type.text = @"待验收";
            self.img_type.image = [UIImage imageNamed:@"type2"];
        }else if ([dataModel.hd_audit_status isEqualToString:@"3"]) {
            /**验收完成*/
            self.lab_type.text = @"验收完成";
            self.img_type.image = [UIImage imageNamed:@"type2"];
        }else if ([dataModel.hd_audit_status isEqualToString:@"4"]) {
            /**结存*/
            self.lab_type.text = @"结存";
            self.img_type.image = [UIImage imageNamed:@"type2"];
            
        }else if ([dataModel.hd_audit_status isEqualToString:@"5"]) {
            /**作废*/
            self.lab_type.text = @"作废";
            self.img_type.image = [UIImage imageNamed:@"type3"];
        }
        
        if ([dataModel.hd_operation_status isEqualToString:@"1"]) {
            self.btn_look.hidden = NO;
            self.btn_del.hidden = YES;
            self.btn_confirm.hidden = YES;
            
        }else{
            self.btn_look.hidden = NO;
            self.btn_del.hidden = NO;
            self.btn_confirm.hidden = NO;
        }
        
        
        
    }else if ([model isKindOfClass:SQConfirmModelData.class]){
        self.btn_del.hidden = YES;
        SQConfirmModelData * dataModel = model;
        self.lab_area.text = dataModel.site_area;
        self.lab_time.text = [NSString formateDate:[dataModel.hd_report_time substringWithRange:NSMakeRange(6,13)]];
        self.lab_description.text = dataModel.hd_danger_description;
        if ([dataModel.hd_audit_status isEqualToString:@"0"]) {
            /**待确认*/
            self.lab_type.text = @"待确认";
            self.img_type.image = [UIImage imageNamed:@"type1"];
        }else if ([dataModel.hd_audit_status isEqualToString:@"1"]) {
            /**待整改*/
            self.lab_type.text = @"待整改";
            self.img_type.image = [UIImage imageNamed:@"type2"];
        }else if ([dataModel.hd_audit_status isEqualToString:@"2"]) {
            /**待验收*/
            self.lab_type.text = @"待验收";
            self.img_type.image = [UIImage imageNamed:@"type2"];
        }else if ([dataModel.hd_audit_status isEqualToString:@"3"]) {
            /**验收完成*/
            self.lab_type.text = @"验收完成";
            self.img_type.image = [UIImage imageNamed:@"type2"];
        }else if ([dataModel.hd_audit_status isEqualToString:@"4"]) {
            /**结存*/
            self.lab_type.text = @"结存";
            self.img_type.image = [UIImage imageNamed:@"type2"];
            
        }else if ([dataModel.hd_audit_status isEqualToString:@"5"]) {
            /**作废*/
            self.lab_type.text = @"作废";
            self.img_type.image = [UIImage imageNamed:@"type3"];
        }
        
//        if ([dataModel.hd_operation_status isEqualToString:@"0"]) {
//            self.btn_look.hidden = NO;
//            self.btn_confirm.hidden = NO;
//            
//        }else{
//            self.btn_look.hidden = NO;
//            self.btn_confirm.hidden = YES;
//        }
        
        
    }else if ([model isKindOfClass:SQRectificationModelData.class]){
        self.btn_del.hidden = YES;
        [self.btn_confirm setTitle:@"整改" forState:UIControlStateNormal];
        SQRectificationModelData * dataModel = model;
        self.lab_area.text = dataModel.site_area;
        self.lab_time.text = [NSString formateDate:[dataModel.hd_report_time substringWithRange:NSMakeRange(6,13)]];
        self.lab_description.text = dataModel.hd_danger_description;
        if ([dataModel.hd_audit_status isEqualToString:@"0"]) {
            /**待确认*/
            self.lab_type.text = @"待确认";
            self.img_type.image = [UIImage imageNamed:@"type1"];
        }else if ([dataModel.hd_audit_status isEqualToString:@"1"]) {
            /**待整改*/
            self.lab_type.text = @"待整改";
            self.img_type.image = [UIImage imageNamed:@"type2"];
        }else if ([dataModel.hd_audit_status isEqualToString:@"2"]) {
            /**待验收*/
            self.lab_type.text = @"待验收";
            self.img_type.image = [UIImage imageNamed:@"type2"];
        }else if ([dataModel.hd_audit_status isEqualToString:@"3"]) {
            /**验收完成*/
            self.lab_type.text = @"验收完成";
            self.img_type.image = [UIImage imageNamed:@"type2"];
        }else if ([dataModel.hd_audit_status isEqualToString:@"4"]) {
            /**结存*/
            self.lab_type.text = @"结存";
            self.img_type.image = [UIImage imageNamed:@"type2"];
            
        }else if ([dataModel.hd_audit_status isEqualToString:@"5"]) {
            /**作废*/
            self.lab_type.text = @"作废";
            self.img_type.image = [UIImage imageNamed:@"type3"];
        }
        
        if ([dataModel.hd_operation_status isEqualToString:@"1"]) {
            self.btn_look.hidden = NO;
            self.btn_confirm.hidden = NO;
            
        }else{
            self.btn_look.hidden = NO;
            self.btn_confirm.hidden = YES;
        }
        
        
    }else if ([model isKindOfClass:SQAcceptanceModelData.class]){
        self.btn_del.hidden = YES;
        [self.btn_confirm setTitle:@"验收" forState:UIControlStateNormal];
        SQAcceptanceModelData * dataModel = model;
        self.lab_area.text = dataModel.site_area;
        self.lab_time.text = [NSString formateDate:[dataModel.hd_report_time substringWithRange:NSMakeRange(6,13)]];
        self.lab_description.text = dataModel.hd_danger_description;
        if ([dataModel.hd_audit_status isEqualToString:@"0"]) {
            /**待确认*/
            self.lab_type.text = @"待确认";
            self.img_type.image = [UIImage imageNamed:@"type1"];
        }else if ([dataModel.hd_audit_status isEqualToString:@"1"]) {
            /**待整改*/
            self.lab_type.text = @"待整改";
            self.img_type.image = [UIImage imageNamed:@"type2"];
        }else if ([dataModel.hd_audit_status isEqualToString:@"2"]) {
            /**待验收*/
            self.lab_type.text = @"待验收";
            self.img_type.image = [UIImage imageNamed:@"type2"];
        }else if ([dataModel.hd_audit_status isEqualToString:@"3"]) {
            /**验收完成*/
            self.lab_type.text = @"验收完成";
            self.img_type.image = [UIImage imageNamed:@"type2"];
        }else if ([dataModel.hd_audit_status isEqualToString:@"4"]) {
            /**结存*/
            self.lab_type.text = @"结存";
            self.img_type.image = [UIImage imageNamed:@"type2"];
            
        }else if ([dataModel.hd_audit_status isEqualToString:@"5"]) {
            /**作废*/
            self.lab_type.text = @"作废";
            self.img_type.image = [UIImage imageNamed:@"type3"];
        }
        
        if ([dataModel.hd_operation_status isEqualToString:@"1"]) {
            self.btn_look.hidden = NO;
            self.btn_confirm.hidden = NO;
            
        }else{
            self.btn_look.hidden = NO;
            self.btn_confirm.hidden = YES;
        }
        
        
    }
}

- (IBAction)clickConfirm:(UIButton *)sender {
    self.cellTitleIndex(@"confirm",(int)self.indexPath.row);
}


- (IBAction)clickLook:(UIButton *)sender {
    self.cellTitleIndex(@"look",(int)self.indexPath.row);
}

- (IBAction)clickDel:(UIButton *)sender {
    self.cellTitleIndex(@"del",(int)self.indexPath.row);
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
